
export const Event = {
    FLUSH_MESSAGE:1,
    FLUSH_ONLINE:2,
    FLUSH_ONLINE_LIST:3
}

export default class MessageHandler {

    constructor() {
        this.handlers = {}
    }

    registeEvent(type,handlerFunc){
        let hs = this.handlers[type]
        if(!hs){
            hs = []
            this.handlers[type]=hs
        }
        hs.push(handlerFunc);
    }

    handle(handleObj) {
        const type = handleObj.type;
        if (!type) {
            return;
        }
        const h = this.handlers[type];
        if (h) {
            for (let i = 0; i < h.length; i++) {
                
                h[i](handleObj)
            }
        }

    }
}
